package org.jeecg.modules.chargeLpg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.chargeLpg.entity.ChargeLpg;
import org.jeecg.modules.chargeLpg.mapper.ChargeLpgMapper;
import org.jeecg.modules.chargeLpg.service.IChargeLpgService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Description: lpg方案
 * @Author: jeecg-boot
 * @Date:   2023-06-19
 * @Version: V1.0
 */
@Service
public class ChargeLpgServiceImpl extends ServiceImpl<ChargeLpgMapper, ChargeLpg> implements IChargeLpgService {

    @Override
    public void updateStatus(ChargeLpg chargeLpg){
        if ("默认方案".equals(chargeLpg.getStatus())){
            ChargeLpg lpg = new ChargeLpg();
            lpg.setStatus("备用方案");
            baseMapper.update(lpg,null);
        }
    }

    @Override
    public Map<String, Object> getProgramme() {
        LambdaQueryWrapper<ChargeLpg> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ChargeLpg::getStatus, "默认方案");
        return baseMapper.selectMaps(queryWrapper).get(0);
    }
}
